<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>个人资料</title>
    <link rel="shortcut icon" href="resources/images/favicon.png">
    <link rel="stylesheet" href="resources/css/bootstrap.css">
    <link rel="stylesheet" href="resources/css/xenon-core.css">
    <link rel="stylesheet" href="resources/css/xenon-forms.css">
    <link rel="stylesheet" href="resources/css/xenon-components.css">
    <link rel="stylesheet" href="resources/css/xenon-skins.css">
    <link rel="stylesheet" href="resources/css/custom.css">
    <!--fonts-->
    <link rel="stylesheet" href="resources/fonts/arimo/css/arimo.css">
    <link rel="stylesheet" href="resources/fonts/linecons/css/linecons.css">
    <link rel="stylesheet" href="resources/fonts/font-awesome-4.7.0/css/font-awesome.css">
    <script src="resources/js/jquery-1.11.1.min.js"></script>

    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
</head>
<body>
<div class="page-title">
<div class="title-env">
    <h1 class="title">查看个人信息</h1>
    <p class="description">用户可以在此页面上，查看个人信息（用户近期动态显示）</p>
</div>
</div>
<section class="profile-env">

<div class="row">
    <div class="col-sm-3">
        <!-- User Info Sidebar -->
            <div class="user-info-sidebar">
                <a href="#" class="user-img">
                    <img src="resources/images/avatar.jpg" alt="user-img" class="img-cirlce img-responsive img-thumbnail" />
                </a>
                <a href="#" class="user-name">
                    <span class="user" name="trueName">未知</span>
                    <span class="user" id="userNo" name="userNo" style="display: none"></span>
                    <span class="user-status is-online"></span>
                </a><br />
                <span class="user-title">
                                    性别：<span class="user" name="sex"></span>
                                </span>
                <span class="user-title" id="birthday">
                              <span class="user" name="createDate"/>
                 </span>  

                <hr />
            </div>
        </div>
        <div class="col-sm-9">
            <!-- User timeline stories -->
            <section class="user-timeline-stories">

                <!-- Timeline Story Type: Status -->
                <article class="timeline-story">

                    <!-- User info -->
                    <header>
                        <div class="user-details">
                            <h5 class="user" name="IDCard">身份证号:</h5>
                            <hr />
                            <h5 class="user" name="phoneNumber">手机号码:</h5>
                            <hr />
                            <h5 class="user" name="email">邮箱地址:</h5>
                            <hr />
                            <h5>工作单位:</h5>
                            <hr />
                            <h5>角色权限:普通用户</h5>
                            <hr />

                        </div>
                        <div class="form-group-separator"></div>
                        <div class="form-group">
                            <a type="button" class="btn btn-info btn-single pull-right" id="updatamibao" data-action="trash" style="margin-left: 5px;color: whitesmoke">修改密保</a>
                            <a type="button" class="btn btn-info btn-single pull-right" id="updata" data-action="trash" style="margin-left: 5px;color: whitesmoke">修改密码</a>
                            <a type="button" class="btn btn-info btn-single pull-right" id="updataInfo" data-action="trash" style="color: whitesmoke">修改信息</a>

                        </div>
                    </header>
                </article>
            </section>

        </div>
    </div>
</section>
<!--底栏注释-->
<footer class="main-footer sticky footer-type-1">
    <div class="footer-inner">
        <!-- Add your copyright text here -->
        <div class="footer-text">
            &copy; 2017-2018 <strong>蓝点工作室</strong> 江西农业大学
            <a href="#" target="_blank">大数据智能猪舍</a>
            - 开发团队:
            <a href="#" target="_blank">蓝点工作室</a>
        </div>
    </div>
</footer>


<!-- Bottom Scripts -->
<script src="resources/js/bootstrap.min.js"></script>
<script src="resources/js/TweenMax.min.js"></script>
<script src="resources/js/resizeable.js"></script>
<script src="resources/js/xenon-api.js"></script>
<script src="resources/js/xenon-toggles.js"></script>
<!-- Imported scripts on this page -->
<script src="resources/js/xenon-widgets.js"></script>
<script src="resources/js/toastr/toastr.min.js"></script>
<!-- JavaScripts initializations and stuff -->
<script src="resources/js/xenon-custom.js"></script>
<script type="text/javascript">
    // Sample Javascript code for this page
    jQuery(document).ready(function($) {

        // Delete Modal-1
        $("#updata").on('click', function() {
            $("#gallery-image-delete-modal1").modal('show');
        });
        $("#updateps").click(function (){
            if ($('#newps').val() != $('#newps2').val()){
                alert('确认密码不一致');
                return;
            }
        	// 修改密码逻辑
            $.ajax({
                url: "http://localhost:8080/IntelligentSystem/user",
                type: 'POST',
                data: {
                    userNo:$('#userNo').html(),
                    oldps:$('#oldps').val(),
                    newps:$('#newps').val(),
                    method: "updatePassword"
                },
                beforeSend: function() {

                },
                success: function(json){
                    var resObj = eval('(' + json + ')');
                    
                    alert(resObj.msg);
                    
                    sessionUser(baseUrl);
                },
                error: function(error){
                    console.log(error);
                }
            });
         });
    });
    var updateUser = function(){
        var bool = $('#inlineRadio1').is(':checked');
        var sex = 1;
        if (bool == true){
            sex = 1;
        }else{
            sex = 0;
        }
        $.ajax({
            url: "http://localhost:8080/IntelligentSystem/user",
            type: 'POST',
            data: {
                userNo:$('#userNo').html(),
                phoneNumber: $('#phoneNumber').val(),
                'sex':sex,
                trueName:$('#trueName').val(),
                email:$('#email').val(),
                personalProfile:$('#personalProfile').val(),
                method: "update"
            },
            beforeSend: function() {

            },
            success: function(json){
                var resObj = eval('(' + json + ')');
                if (resObj.code == '1'){
                    alert(resObj.msg);
                    }
                sessionUser(baseUrl);
            },
            error: function(error){
                console.log(error);
            }
        });
    };
    var updateMibao = function(){
        var bool = $('#inlineRadio1').is(':checked');
        var sex = 1;
        if (bool == true){
            sex = 1;
        }else{
            sex = 0;
        }
        $.ajax({
            url: "http://localhost:8080/IntelligentSystem/user",
            type: 'POST',
            data: {
                userNo:$('#userNo').html(),
                question:$('#question').val(),
                answer:$('#answer').val(),
                method: "updateMibao"
            },
            beforeSend: function() {

            },
            success: function(json){
                var resObj = eval('(' + json + ')');
                if (resObj.code == '1'){
                    alert(resObj.msg);
                    }
                sessionUser(baseUrl);
            },
            error: function(error){
                console.log(error);
            }
        });
    };
    // Sample Javascript code for this page
    jQuery(document).ready(function($) {
    	var baseUrl = "http://localhost:8080/IntelligentSystem";
        // Delete Modal-1
        $("#updataInfo").on('click', function() {
            $("#gallery-image-delete-modal2").modal('show');
            // 
            
            sessionUser(baseUrl);
            var e = $('#userSex').html();
            if (e == "男"){
                $("#inlineRadio1").prop("checked",true);
                }else {
                    $("#inlineRadio2").prop("checked",true);
                    }
            
        });
        // 修改信息的提交时间注册
        $('#updateUser').click(updateUser);              
    });

    // Sample Javascript code for this page
    jQuery(document).ready(function($) {

        // Delete Modal-1
        $("#updatamibao").on('click', function() {
            $("#gallery-image-delete-modal").modal('show');
            var baseUrl = "http://localhost:8080/IntelligentSystem";
            sessionUser(baseUrl);
        });
        $('#updateMibao').click(updateMibao);
    });


    
</script>

<!-- Gallery Delete Image (Confirm)-->
<div class="modal fade" id="gallery-image-delete-modal1" data-backdrop="static">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">修改密码</h4>
            </div>
            <form class="form-horizontal">
                <div class="modal-body">
                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="field-1">原密码</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="oldps"  placeholder="" >
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="field-1">新密码</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="newps" placeholder="">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="field-1">确定密码</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="newps2" placeholder="">
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" id="updateps" class="btn btn-white" data-dismiss="modal">确定</button>
                    <button type="button" class="btn btn-danger" data-dismiss="modal">退出</button>
                </div>
            </form>
        </div>
    </div>
</div>

<!-- Gallery Delete Image (Confirm)-->
<div class="modal fade" id="gallery-image-delete-modal2" data-backdrop="static">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">修改信息</h4>
            </div>
            <form class="form-horizontal">
                <div class="modal-body">
                    <form role="form" class="form-horizontal">
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="field-1">真实姓名</label>
                            <div class="col-sm-10">
                                <input type="text" class="user form-control" id="trueName" name="trueName" value="">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="field-1">手机号</label>
                            <div class="col-sm-10">
                                <input type="text" class="user form-control" id="phoneNumber" name="phoneNumber" value="">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="field-1">邮箱地址</label>
                            <div class="col-sm-10">
                                <input type="text" class="user form-control" id="email" name="email">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">性别</label>
                            <div class="col-sm-10">
                                <p>

                                    <label class="radio-inline">
                                        <input type="radio" name="sex" id="inlineRadio1" value="1"> 男
                                    </label>
                                    <label class="radio-inline">
                                        <input type="radio" name="sex" id="inlineRadio2" value="0"> 女
                                    </label>
                                </p>
                                <span id="userSex" class="user" name="sex" style="display: none"></span>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">个人说明</label>
                            <div class="col-sm-9">
                                <input type="text" id="personalProfile" class="user form-control datepicker" name="personalProfile" value="">
                            </div>
                        </div>


                        <div class="modal-footer">
                            <button type="button" id="updateUser" class="btn btn-white" data-dismiss="modal">确定</button>
                            <button type="button" class="btn btn-danger" data-dismiss="modal">退出</button>
                        </div>
                    </form>
                </div>
            </form>
        </div>
    </div>
</div>

<!-- Gallery Delete Image (Confirm)-->
<div class="modal fade" id="gallery-image-delete-modal" data-backdrop="static">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">修改密保</h4>
            </div>
            <form class="form-horizontal">
                <div class="modal-body">
                    <div class="form-group">
                        <label class="col-sm-3 control-label" for="field-1">密保问题</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control user" id="question" name="question" placeholder="Placeholder" readonly="readonly">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label" for="field-1">原密保答案</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control user"  name="answer" placeholder="" readonly="readonly">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label" for="field-1">新密保答案</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" id="answer" name="answer" placeholder="">
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" id="updateMibao" class="btn btn-white" data-dismiss="modal">确定</button>
                    <button type="button" class="btn btn-danger" data-dismiss="modal">退出</button>
                </div>
            </form>
        </div>
    </div>
</div>
<!-- <script class="resources library" src="../assets/js/area.js" type="text/javascript"></script>
 -->

<script type="text/javascript">
    // 这里 _init_area();
</script>
<script type="text/javascript">
    var Gid = document.getElementById;

    var showArea = function() {

        Gid('show').innerHTML = "<h3>省" + Gid('s_province').value + " - 市" +

            Gid('s_city').value + " - 县/区" +

            Gid('s_county').value + "</h3>"

    }

    Gid('s_county').setAttribute('onchange', 'showArea()');
</script>
<script src="resources/js/common.js"></script>
<script type="text/javascript">
    // 这里获得User信息到页面
    var baseUrl = "http://localhost:8080/IntelligentSystem";
    sessionUser(baseUrl);
    
</script>
</body>
</html>